<?php

global $_W, $_GPC;
			load()->func('tpl');
			$uniacid=intval($_W['uniacid']);
			$sql = " WHERE `uniacid`= {$uniacid} ";
	    	$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
		
 if ($operation == 'display') {
			$pindex = max(1, intval($_GPC['page']));
            $psize = 10;
			$sum =pdo_fetchcolumn("SELECT sum(fkey) FROM ".tablename('bbyscm_card_formid').$sql." limit ".$pindex * $psize, $params);
			$list = pdo_fetchall("SELECT a.* FROM " . tablename('bbyscm_card_formid') . " as a WHERE a.uniacid = $uniacid $condition ORDER BY a.createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
			$total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('bbyscm_card_formid') . " as a WHERE a.uniacid = $uniacid  $condition");
            $pager = pagination($total, $pindex, $psize);
			
} else if($operation == 'clear') {
	  $d_time = time()-604800;
	  
	  pdo_delete('bbyscm_card_formid', array('fkey' => 0 ));
	  pdo_delete('bbyscm_card_formid', array('formid' => 'the formId is a mock one' ));
	  
	  pdo_query("DELETE FROM ".tablename('bbyscm_card_formid')."WHERE `uniacid`= :uniacid and `createtime` < {$d_time}", array(':uniacid' => $uniacid));
	  message('一键清除数据成功！'.$slides, $this->createWebUrl('formid', array('op'=>'display')), 'success');

} else if($operation == 'delete') {
    $id=intval($_GPC['id']);
	 $category=pdo_fetch("SELECT id FROM ".tablename('bbyscm_card_formid')." WHERE id = '$id'");
    if(empty($category)){
		
        message('抱歉，资源不存在或是已经被删除！', $this->createWebUrl('formid', array('op'=>'display')), 'error');
    }
   
    pdo_delete('bbyscm_card_formid', array('id' => $id));
   
    message('删除数据成功！', $this->createWebUrl('formid', array('op'=>'display')), 'success');
}
include $this->template('web/formid');